import {  UserListResponse, UserServiceClient } from '@libs/common/protos/user/user';
import { Observable } from 'rxjs';
import { Client,type ClientGrpc } from '@nestjs/microservices';
import { Body, Controller, Get, OnModuleInit, Post } from '@nestjs/common';
import { userGrpcClientOptions } from './user.client';
import { ApiBody, ApiOperation, ApiTags } from '@nestjs/swagger';
import { UserDto } from './user.dto';
import { UserListDto } from './userList.dto';
@ApiTags('用户服务')
@Controller('user')
export class UserController implements OnModuleInit {
  @Client(userGrpcClientOptions)
  private readonly userClient:ClientGrpc;

  private userServiceClient: UserServiceClient;
  onModuleInit(): any {
    this.userServiceClient = this.userClient.getService<UserServiceClient>('UserService');
  }

  @ApiOperation({
    summary: '获取用户列表',
    description: '根据分页参数和筛选条件获取用户列表',
  })
  @ApiBody({type:UserListDto})
  @Post('list')
  getUserList(@Body() request:UserListDto ): Observable<UserListResponse> {
    return this.userServiceClient.getUserList(request);
  }



}